{% extends "base.html" %}
{% comment %}
Copyright 2011 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This is the Django template for importing tasks.
{% endcomment %}
{% block title %}Import{% endblock %}
{% block heading %}Please fill out the form below{% endblock %}
{% block head %}
{% if refresh %}
<meta http-equiv="refresh" content="10">
{% endif %}
{% endblock %}

{% block body %}
<div class="break">
  <p>Please note that at this time we support a maximum file size of 100 KB.  If
  you need to upload a larger quantity of data than that allows, we recommend
  that you break it down into groups based on some sort of category and upload
  the files separately.</p>
  {% if error == "REQUIRED_FIELD" %}
  <p><b>You must fill out the form in order to import tasks.</b></p>
  {% endif %}
  {% if error == "FILE_TOO_LARGE" %}
  <p><b>File is larger than 100 KB.</b></p>
  {% endif %}
  {% if snapshots %}
  <p>Import Status:
  <ul>
  {% for snapshot, title in snapshots %}
    <li>{{ snapshot.timestamp|date:"m/d/Y h:i:s a \U\T\C" }} -
    {% if snapshot.status == "completed" %}
    Complete. View in Gmail as task list "{{ title }}"
    <a href="/delete?id={{ snapshot.key.id }}&amp;import=y">[x]</a>
    {% endif %}{% if snapshot.status == "error" %}
    ERROR: {{ snapshot.errorMessage }}
    <a href="/delete?id={{ snapshot.key.id }}&amp;import=y">[x]</a>
    {% endif %}{% if snapshot.status == "building" %}
    Importing...
    {% endif %}</li>
  {% endfor %}
  </ul></p>
  {% endif %}
  <form enctype="multipart/form-data" method="POST" action="/import">
    <table>
      <tr>
        <td><label for="name">Task List Name:</label></td>
        <td><input type="text" id="name" name="name" /></td>
      </tr>
      <tr>
        <td><label for="file">File to Import:</label></td>
        <td><input type="file" id="file" name="file" /></td>
      </tr>
      <tr>
        <td><label for="format">Format:</label></td>
        <td>
          <select id="format" name="format">
            <option value="csv">Outlook</option>
            <option value="ics">iCalendar</option>
          </select>
        </td>
      </tr>
    </table>
    <button type="submit">Import Tasks</button>
  </form>
</div>
{% endblock %}
